﻿using System.Collections.Generic;
using System.Web.Mvc;
using Keleyi.Com.KBLL;
using Keleyi.Com.Model;

namespace Keleyi.Com.KWeb.Controllers
{
    public class MessageController : Controller
    {
        //
        // GET: /Message/

        public ActionResult Index()
        {
            Message k_message = new Message();
            IList<MessageInfo> k_infoList = k_message.GetList();

            ViewBag.Count = k_infoList.Count.ToString();
            return View(k_infoList);
        }

        //
        // GET: /Message/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Message/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Message/Create

        [ValidateInput(false)]
        [HttpPost]
        public string Create(FormCollection collection)
        {
            Message m_message = new Message();
            return m_message.Add(collection["ktitle"], collection["kcontent"], collection["kemail"], collection["kqq"]);

        }

        //
        // GET: /Message/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Message/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            
                return View();
        }

        //
        // GET: /Message/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Message/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}